//
//  WFChannelTableViewCell.m
//  FAKER
//
//  Created by Jianwei on 15/11/4.
//  Copyright © 2015年 YHLai. All rights reserved.
//

#import "WFChannelTableViewCell.h"
#import "FitHeader.h"
#import "AllHeader.h"
@implementation WFChannelTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createCell];
    }
    return self;
}
- (void)createCell
{
    _is_newImageView = [[BaseClassImageView alloc]init];
    [CONTENT_VIEW addSubview:_is_newImageView];
    
    _list_iconImageView = [[BaseClassImageView alloc]init];
    [CONTENT_VIEW addSubview:_list_iconImageView];
    
    _titleLabel = [[BaseClassLabel alloc]init];
    [CONTENT_VIEW addSubview:_titleLabel];
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    _list_iconImageView.frame = CGRectMake(20 * FITWIDTH, 15 * FITWIDTH, 30 * FITWIDTH, 30 * FITWIDTH);
    _titleLabel.font = [UIFont fontWithBold:1 IPhone6sPlus:14 Iphone6s:13 Iphone5s:12 Iphone4s:11];
    _titleLabel.frame = CGRectMake(_list_iconImageView.X + _list_iconImageView.WIDTH + 8 * FITWIDTH, 20 * FITWIDTH, [Adaptive AdaptiveWidthByString:_model.title Height:20 * FITWIDTH FontSize:_titleLabel.font.pointSize + .8] * FITWIDTH, 20 * FITWIDTH);
    
    _is_newImageView.frame = CGRectMake(_titleLabel.X + _titleLabel.WIDTH + 5, 25 * FITWIDTH, 10 * FITWIDTH, 10 * FITWIDTH);
    if (NSUSERDEFAULTS_NIGHT) {
        _titleLabel.textColor = [UIColor grayColor];
    }
}
- (void)setModel:(WFChannelListModel *)model
{
    _model = model;
    [_list_iconImageView sd_setImageWithURL:[NSURL URLWithString:_model.list_icon] placeholderImage:[UIImage imageNamed:@"PlaceHolder"]];
    _titleLabel.text = _model.title;
    if (_model.is_new) {
        _is_newImageView.image = [UIImage imageNamed:@"newchannel_table@3x"];
    }
    else
    {
        _is_newImageView.image = [UIImage imageNamed:@""];
    }
}

@end
